from __future__ import print_function
import sys

def auto_complete(line_split, cword, cargv, line, cursor):
  """
  python version of arguments from bash autocompletion.

  Args:
  line_split : string  COMP_WORDBREAKS (what readline uses to split argv)
  cword : int  COMP_CWORD word containing cursor"
  cargv : list.<str> COMP_WORDS
  line : str COMP_LINE
  cursor : int COMP_POINT
  """
  print(cargv, file=sys.stderr)
  if(cursor == 1):
    print("build test run")
  else:
    rule_complete(cword)

def check_for_auto_complete():
  if(len(sys.argv) > 1 and sys.argv[1] == '--cmplt'):
    auto_complete(line_split=sys.argv[2],
                  cword= int(sys.argv[3]),
                  line= sys.argv[4],
                  cursor= int(sys.argv[5]),
                  cargv= sys.argv[6:])
    return True
